 var id = getvl("id");
 	    $(function(){
 	   if(id!=''){
 	   	useryouhuiquan();
 	   }else{
 	   	
 	   }
 });
 var currentPage=1;
var ss=0;
function useryouhuiquan() {
        if(currentPage==1 || currentPage==2 || ss!=0){
        	
	$.ajax({
		url: urlcore + '/api/coupon/getCouponList?current='+currentPage+"&shopId="+id,
		type: "get",
		dataType: 'json',
		contentType: "application/json;charset=utf-8",
		success:function(data){
			if (data.success == true) {
				ss=data.data.list.length;
			$.each(data.data.list, function(y,n) {
				var limit_time="";
		var gmtDatetime =n.startTime;
	       limit_time=n.endTime;
		    limit_time+="00:00:00";
		    var guoqishijian=new Date(limit_time);
		    var datas=new Date();
		        if(n.couponStatus==1){
		        	if(guoqishijian.getTime()>datas.getTime()){
	var OA_task_1='<li class="m_main mui-table-view-cell">'+
'		<div class="mui-slider-handle">'+
'		    <div class="a_discount">'+
'		        <ul class="a_content clearfix">'+
'		            <li class="a_infor">'+
'		                <h3>'+n.couponname+'</h3>'+
'		                <h3>满'+n.limitMoney+'元使用'+
               '</h3>'+
'		            </li>'+
'		            <li class="a_price">'+
'		                <p><span>￥</span>'+n.saveMoney+'</p>'+
'		            </li>'+
'		        </ul>'+
'		        <div class="a_time1">'+
'		            <p>有效期'+gmtDatetime+'至'+limit_time+'</p>'+
'		        </div>'+
'		    </div>'+
'		</div>'+
'	    <div class="mui-slider-right mui-disabled">'+
'			<a class="mui-btn mui-btn-red" onclick="shanchu('+n.id+')">领取</a>'+
'		</div>'+
'	</li>';
             $("#OA_task_1").append(OA_task_1);
		        
		        }
		        	}
						});
			}else{
				alert(data.msg);
			}
		},
		error:function() {
			/* Act on the event */
			alert("error");
		}
	});	
        	  
        }
}


function shanchu(tes){
	  $.ajax({
        url:  urlcore + "/api/userCoupon/add",
        type: "post",
        contentType: "application/json;charset=utf-8",
        data: JSON.stringify({
        	"userId":uuuuid,
            "shopId": id,
            "couponId":tes
        }),
        dataType: "json",
        success:function(data){
            if (data.success == true) {
            	alert("已放入优惠券列表");
            } else if (data.code == 'OVERTIME') {
                var thisUrl = window.location.href;
                if (thisUrl.indexOf('login.html') <= -1) {
                    top.window.location.href = "login.html";
                }
            } else {
                alert(data.msg);
            }
        },
        error: function() {
            alert("error");
        }
    });
}



